﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using System.Web.Mvc.Filters;

namespace Clover.BaseAuth
{
    public class DefaultRolePermissionProvider : IPermissionProvider
    {
        internal static DefaultRolePermissionProvider _instance { get; set; }

        public static DefaultRolePermissionProvider Default
        {
            get => _instance ?? new DefaultRolePermissionProvider();
            set => _instance = value;
        }

        protected virtual IEnumerable<Enum> GetPermissions() {
            return Enumerable.Empty<Enum>();
        }

        protected virtual IEnumerable<Enum> GetPermissions(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
        {
            return Enumerable.Empty<Enum>();
        }

        IEnumerable<Enum> IPermissionProvider.GetPermissions()
        {
            return Default.GetPermissions();
        }

        IEnumerable<Enum> IPermissionProvider.GetPermissions(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
        {
            return Default.GetPermissions(controllerContext, actionDescriptor);
        }

    }
}
